﻿<?xml version="1.0"?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">

  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="databaseSettings"/>
  </object>


  <db:provider id="DbProvider"
				 provider="MySql"
				 connectionString="Data Source=${db.datasource};Database=${db.database};User ID=${db.user};Password=${db.password};charset=utf8"/>


  <object id="NHibernateSessionFactory" autowire="byType" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
    <property name="DbProvider" ref="DbProvider"/>
    <property name="MappingAssemblies">
      <list>
        <value>Mani.Patient.Business</value>
      </list>
    </property>
    <property name="HibernateProperties">
      <dictionary>

        <entry key="hibernate.connection.provider"
					   value="NHibernate.Connection.DriverConnectionProvider"/>

        <entry key="hibernate.dialect"
					   value="NHibernate.Dialect.MySQLDialect"/>

        <entry key="hibernate.connection.driver_class"
					   value="NHibernate.Driver.MySqlDataDriver"/>

        <entry key="hibernate.show_sql" value="true"/>
        <entry key="hibernate.use_proxy_validator" value="true"/>
        
        <!-- Doesn't work for mysql (Collation & charset problem) -->
        <!--<entry key="hibernate.hbm2ddl.auto" value="update"/>-->

        <entry key="hibernate.cache.provider_class"
        value="NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache" />

      </dictionary>
    </property>
  </object>

  <object id="HibernateTransactionManager" autowire="byType"
		  type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate12">
    <property name="DbProvider" ref="DbProvider"/>
    <property name="SessionFactory" ref="NHibernateSessionFactory"/>
  </object>

  <object id="hibernateTemplate" type="Spring.Data.NHibernate.HibernateTemplate" autowire="byType">
    <property name="SessionFactory" ref="NHibernateSessionFactory" />
    <property name="TemplateFlushMode" value="Commit" />
    <property name="CacheQueries" value="true" />
  </object>

  <object id="visitDao" type="Mani.Patient.Business.Dao.VisitDao, Mani.Patient.Business" autowire="byType" singleton="true" />
  <object id="fileDao" type="Mani.Patient.Business.Dao.FileDao, Mani.Patient.Business" autowire="byType" singleton="true" />
  <object id="patientDao" type="Mani.Patient.Business.Dao.PatientDao, Mani.Patient.Business" autowire="byType" singleton="true" />
  <object id="questionDao" type="Mani.Patient.Business.Dao.QuestionDao, Mani.Patient.Business" autowire="byType" singleton="true" />
  <object id="questionTypeDao" type="Mani.Patient.Business.Dao.QuestionTypeDao, Mani.Patient.Business" autowire="byType" singleton="true" />
</objects>